import wujiangList from "./wujiang.json";

const getWujiang = (name: string, type: string) => {
  let data: any = wujiangList.find((item) => item.uniqueName === name);
  if (!data) {
    return {};
  }
  return data![type];
};

interface ZhuangTaiInfo {
  huihe: number;
  jilv: number;
  jiacheng: number;
  laiyuan: Wujiang;
  laiyuanZhanfa: string;
  num: number;
  bukeqingchu: boolean;
  shoushang: number[];
}
export const ZhuangTaiMap = {
  hunluan: "混乱",
  youyu: "犹豫",
  qiezhan: "怯战",
  baozou: "暴走",
  shanghaijiangdi: "伤害降低",
  weikun: "围困",
  lianji: "连击",
  jijiu: "急救",
  guibi: "规避",
  fanji: "反击",
  xianshou: "先手",
  celueshanghai: "策略伤害",
};
export interface ZhuangTai {
  hunluan: ZhuangTaiInfo;
  youyu: ZhuangTaiInfo;
  qiezhan: ZhuangTaiInfo;
  baozou: ZhuangTaiInfo;
  shanghaijiangdi: ZhuangTaiInfo;
  weikun: ZhuangTaiInfo;
  celueshanghai: ZhuangTaiInfo;

  lianji: ZhuangTaiInfo;
  jijiu: ZhuangTaiInfo;
  guibi: ZhuangTaiInfo;
  fanji: ZhuangTaiInfo;
  xianshou: ZhuangTaiInfo;
}

export interface Wujiang {
  name: string;
  hp: number;
  lv: number;
  v: number;
  atk: number;
  def: number;
  mou: number;
  ji: string[];
  distance: number;
  type: string;
  contory: string;
  lr: "l" | "r";
  zhuangtai: ZhuangTai;
  zhiliao: number;
  shangbing: number;
  shanghai: number;
  [key: string]: any;
}

// 模拟参战方
export const wujiang = (name: string, hp: number, lv: number, ji: string[], lr: "l" | "r"): Wujiang => {
  return {
    name: getWujiang(name, "name"),
    hp: hp,
    lv: lv,
    v: getWujiang(name, "speed") + getWujiang(name, "speedGrow") * lv,
    atk: getWujiang(name, "attack") + getWujiang(name, "attGrow") * lv,
    def: getWujiang(name, "def") + getWujiang(name, "defGrow") * lv,
    mou: getWujiang(name, "ruse") + getWujiang(name, "ruseGrow") * lv,
    // 技能
    ji: [getWujiang(name, "methodName"), ...ji],
    // 攻击距离
    distance: getWujiang(name, "distance"),
    // 兵种
    type: getWujiang(name, "type"),
    // 阵营
    contory: getWujiang(name, "contory"),
    // 造成的伤害
    shanghai: 0,
    // 造成的治疗
    zhiliao: 0,
    // 当前伤兵
    shangbing: 0,
    lr,
    zhuangtai: {
      hunluan: { huihe: 0, num: 0, jilv: 0, laiyuanZhanfa: "", jiacheng: 0, laiyuan: {} as Wujiang, bukeqingchu: false, shoushang: [] },
      youyu: { huihe: 0, num: 0, jilv: 0, laiyuanZhanfa: "", jiacheng: 0, laiyuan: {} as Wujiang, bukeqingchu: false, shoushang: [] },
      qiezhan: { huihe: 0, num: 0, jilv: 0, laiyuanZhanfa: "", jiacheng: 0, laiyuan: {} as Wujiang, bukeqingchu: false, shoushang: [] },
      baozou: { huihe: 0, num: 0, jilv: 0, laiyuanZhanfa: "", jiacheng: 0, laiyuan: {} as Wujiang, bukeqingchu: false, shoushang: [] },
      lianji: { huihe: 0, num: 0, jilv: 0, laiyuanZhanfa: "", jiacheng: 0, laiyuan: {} as Wujiang, bukeqingchu: false, shoushang: [] },
      jijiu: { huihe: 0, num: 0, jilv: 0, laiyuanZhanfa: "", jiacheng: 0, laiyuan: {} as Wujiang, bukeqingchu: false, shoushang: [] },
      guibi: { huihe: 0, num: 0, jilv: 0, laiyuanZhanfa: "", jiacheng: 0, laiyuan: {} as Wujiang, bukeqingchu: false, shoushang: [] },
      fanji: { huihe: 0, num: 0, jilv: 0, laiyuanZhanfa: "", jiacheng: 0, laiyuan: {} as Wujiang, bukeqingchu: false, shoushang: [] },
      shanghaijiangdi: { huihe: 0, num: 0, jilv: 0, laiyuanZhanfa: "", jiacheng: 0, laiyuan: {} as Wujiang, bukeqingchu: false, shoushang: [] },
      weikun: { huihe: 0, num: 0, jilv: 0, laiyuanZhanfa: "", jiacheng: 0, laiyuan: {} as Wujiang, bukeqingchu: false, shoushang: [] },
      xianshou: { huihe: 0, num: 0, jilv: 0, laiyuanZhanfa: "", jiacheng: 0, laiyuan: {} as Wujiang, bukeqingchu: false, shoushang: [] },
      celueshanghai: { huihe: 0, num: 0, jilv: 0, laiyuanZhanfa: "", jiacheng: 0, laiyuan: {} as Wujiang, bukeqingchu: false, shoushang: [] },
    },
    zhanfa: {},
  };
};
